package com.clstu.tankgame5;

import java.awt.*;
import java.util.Vector;

public class Tank implements Runnable{
    private int x;
    private int y;
    private int direct;
    private int speed;
    private Shot shot = null;
    private Vector<Shot> shots = new Vector();
    private boolean isLive = true;

    public Shot getShot() {
        return shot;
    }

    public void setShot(Shot shot) {
        this.shot = shot;
    }

    public Vector<Shot> getShots() {
        return shots;
    }


    public boolean isLive() {
        return isLive;
    }

    public void setLive(boolean live) {
        isLive = live;
    }

    public Tank(int x, int y, int direct) {
        this.x = x;
        this.y = y;
        this.direct = direct;
        this.speed = 1;
    }

    public void moveUP(){//控制在方框内可以上下左右的移动
        if(y>0)
        y-=speed;
    }
    public void moveDown(){
        if(y+100<750)
        y+=speed;
    }
    public void moveLeft(){
        if(x>0)
        x-=speed;
    }
    public void moveRight(){
        if(x+60d<1000)
        x+=speed;
    }

    public int getDirect() {
        return direct;
    }

    public void setDirect(int direct) {
        this.direct = direct;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public Shot shot(Color color){//根据坦克方向返回一颗该方向上的子弹
        switch (direct){
            case 0:
                return new Shot(getX()+20,getY(),true,getDirect(),color);
            case 1:
                return new Shot(getX(),getY()+20,true,getDirect(),color);
            case 2:
                return new Shot(getX()+20,getY()+60,true,getDirect(),color);
            case 3:
                return new Shot(getX()+60,getY()+20,true,getDirect(),color);
            default:
                return null;
        }
    }

    @Override
    public void run() {

    }
}
